# -*- coding: utf-8 -*-
# @Author: QX
# @File: day4_0041init.py
'''
第4课：
1.inspector的使用方法
2.启动APP的基本参数
3.元素定位方法
'''
from time import sleep

from  appium   import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.common.by import By

dic = {
  "platformName": "Android",
  "appium:platformVersion": "9",
  "appium:appPackage": "com.android.settings",
  "appium:appActivity": ".Settings",
  "appium:deviceName": "emulator-5554",
  "appium:automationName": "UIAutomator2"
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',dic)
sleep(2)
#对一个元素定位--1.找到元素的属性2.通find_elementr找到元素
# ele=driver.find_element(By.XPATH,'//android.widget.ImageButton[@content-desc="向上导航"]')
# ele.click()

ele=driver.find_element(AppiumBy.XPATH,'//android.widget.ImageButton[@content-desc="向上导航"]')
ele.click()

ele=driver.find_element(MobileBy.XPATH,'//android.widget.ImageButton[@content-desc="向上导航"]')
ele.click()

# ele=driver.find_element('xpath','//android.widget.ImageButton[@content-desc="向上导航"]')
# ele.click()
